package oop.conf;

import org.apache.commons.lang.StringUtils;

import oop.controller.module.Module;

public class ModuleDescriptor {

	private String name;
	private String title;
	private String position;
	private boolean loginRequired = false;
	private String requiredGroup = null;
	private int order;
	private String page;
	private String clazz;

	public String getName() {
		return name;
	}

	public String getPosition() {
		return position;
	}

	public String getTitle() {
		return title;
	}

	public void setPosition(String position) {
		this.position = position;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public boolean isLoginRequired() {
		return loginRequired;
	}

	public void setLoginRequired(boolean loginRequired) {
		this.loginRequired = loginRequired;
	}

	public String getRequiredGroup() {
		return requiredGroup;
	}

	protected void setRequiredGroup(String requiredGroup) {
		this.requiredGroup = requiredGroup;
	}

	public int getOrder() {
		return order;
	}

	public void setOrder(int order) {
		this.order = order;
	}

	public String getPage() {
		return StringUtils.defaultIfEmpty(page, name + ".jsp");
	}

	public void setPage(String page) {
		this.page = page;
	}

	public void setName(String name) {
		this.name = name;
	}

	@SuppressWarnings("unchecked")
	public Class<Module> getModuleClass() throws ClassNotFoundException {
		return (Class<Module>) Class.forName(clazz);
	}
	
}
